<?  
include_once("codelibrary/inc/variables.php");
include_once("session.php");
include_once("codelibrary/inc/functions.php");

$business_id = $_SESSION['business_id'];

if(isset($_REQUEST['staff_id']))
{
	$staff_id = $_REQUEST['staff_id'];
	$business_id = $_REQUEST['business_id'];
	$qry = mysql_query("select * from staff where staff_id = '".$staff_id."' and business_id = '".$business_id."'");
	$record = mysql_fetch_array($qry);
}
//-----------------------------   Delete code Start here --------------------//	

if(isset($_REQUEST['del']))
{
	$del = $_REQUEST['del'];
	mysql_query("delete from staff_offdays where off_id = '".$del."'");
}

//-------------------------------  End of delete code ---------------------//

if(isset($_REQUEST['d']))
{
	$d= $_REQUEST['d'];
}

?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="LTR" lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Online Appointment</title>
</script>
<script src="calendar/calendar2.js"></script>
<script>
function pass(t, id, business)
{
	var agree = confirm("Are you sure you want to delete the selected Items");
	if(agree)
		window.location.href="staff_offdays.php?staff_id="+t+"&del="+id+"&business_id="+business;
	else
		return false;
}
</script>

<base >
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<title>Staff Management</title>

</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">


<table cellpadding="0" cellspacing="0" border="0"><tr>
  <td style="background:url(images/top.gif) repeat-x top; ">
<table cellpadding="0" cellspacing="0" border="0" style="width:764px" align="center"> 
	<tr>
		<td>
			<table cellpadding="0" cellspacing="0" border="0" style="height:57">
				<tr>
					<td height="57">
<? html_header(); ?>					</td>
				</tr>
			</table>


		</td>
	</tr>
	<tr>
		<td>





<table border="0" width="105%" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top" class="col_left">

<table border="0"cellspacing="0" cellpadding="0" class="box_width_left">
	<tr><td width="100%">
		<table border="0" cellspacing="0" cellpadding="0">
<tr><td>

<table border="0" width="100%" cellspacing="0" cellpadding="0" class="">
  <tr>
    <td>
    <table border="0" width="100%" cellspacing="0" cellpadding="0"  class="" height="91">
  <tr>
    <td align="center" height="91">
    <img border="0" src="images/logo.jpg" width="208" height="86"></td>
  </tr>
</table>
</td>
  </tr>
</table>
</td></tr>


          <tr>
            <td>
<table border="0" width="100%" cellspacing="0" cellpadding="0"  class="box_header_txt" height="48">
  <tr>
    <td style="background-image: url(images/1_bg2-2.gif)" height="1">
      <p style="margin-top: 16"> </td>
  </tr>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="0"   style="border-bottom:12px solid #ffffff;">
  <tr>
    <td>
    <table border="0" width="100%" cellspacing="0" cellpadding="0"  style="margin-bottom:0px;background:#7C7C7C url(images/1_line.gif) no-repeat left bottom;" >
  <tr>
    <td  style="padding:3px 16px 8px 25px;">
      <table width="100%" border="0" cellpadding="5" cellspacing="3">
        <tr>
          <td colspan="2" align="left"><a href="profile.php?business_id=<? echo $business_id;?>&staff_id=<? echo $staff_id;?>" class="topmenulink">Profile Information </a> </td>
        </tr>
        <tr>
          <td colspan="2"><a href="staff_schedule.php?business_id=<? echo $business_id;?>&staff_id=<? echo $staff_id;?>" class="topmenulink">Schedule</a></td>
        </tr>
        <tr>
          <td colspan="2"><a href="service_offered.php?business_id=<? echo $business_id;?>&staff_id=<? echo $staff_id;?>" class="topmenulink">Services Offered </a></td>
        </tr>
        <tr>
          <td colspan="2"><a href="staff_offdays.php?business_id=<? echo $business_id;?>&staff_id=<? echo $staff_id;?>" class="topmenulink">Days Off </a></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</td>
  </tr>
</table>
            </td>
          </tr>


          <tr>
            <td class="">&nbsp;
</td>
          </tr>

		</table>
	</td>
	<td><img src="images/spacer.gif" border="0" alt="" width="15" height="1"></td></tr>
</table>

    </td>

    <td width="100%" valign="top">
<table border="0" width="100%" cellspacing="0" cellpadding="0"  class="cont_header_txt">
  <tr>
    <td>
			<table border="0" cellpadding="0" cellspacing="0" bgcolor="#EAEAEA" class="cont_header_txt">
				<tr>
					<td><img src="images/1_q1.gif" border="0" alt="" width="45" height="39"></td>
					<td style="width:100%"><? echo $record['first_name']." ".$record['last_name'];?></td>
					<td><img src="images/1_q2.gif" border="0" alt="" width="10" height="39"></td>
				</tr>
			</table>										 
			</td>
  </tr>
</table>


						<form name="frm" action="" method="post" >
						<table cellpadding="0" cellspacing="0" border="0" style="border:0px solid #DEDEDE; border-width:0px 1px 0px 1px;">
                          <tr>
                            <td style="background:#ffffff;border:0px solid #ffffff; border-width:18px 5px 10px 5px;"><!-- new_products //-->
                                <table border="0" width="" cellspacing="0" cellpadding="0" >
                                  <tr>
                                    <td><table width="90%" border="0" align="center" cellpadding="1" cellspacing="0" >
                                  <tr> 
                                    <td colspan="4"></td>
                                  </tr>
                                  <tr> 
                                    <td colspan="4" align="center">&nbsp;</td>
                                  </tr>
                                  <?
				 if(isset($_REQUEST['add']))
				 {
					 $date = $_REQUEST['date1'];
					  $date_in = date("Y-m-d",strtotime($date));
					 $option = $_REQUEST['radiobutton'];
					 if($date != "")
					 {
							if($option != "")
							{
								$insert = mysql_query("insert into staff_offdays(business_id, staff_id, date, sel_format) values('".$business_id."', '".$staff_id."', '".$date_in."', '".$option."')");
							}else
							{
		echo"<script>window.location.href='staff_offdays.php?staff_id=$staff_id&business_id=$business_id&d=$date&err=1';</script>";
							}
					 }else
					 {
						echo"<script>window.location.href='staff_offdays.php?staff_id=$staff_id&business_id=$business_id&err=1';</script>";
					 }
				 }		
			
					
					$select = mysql_query("select * from staff_offdays where staff_id = '".$staff_id."'");
					if(mysql_num_rows($select) != 0)
					{
					  ?>
                                  <tr> 
                                    <td height="24" colspan="4" align="center" bgcolor="#EAEAEA" class="header-txt">Days 
                                      Off </td>
                                  </tr>
                                  <? 
					  while($data = mysql_fetch_array($select)) 
					  {
						  $option = $data['sel_format'];
						  $date1 = $data['date'];
						  $date1 = split("-", $date1);
						  $month = $date1[1];
						  $day = $date1[2];
						  $year = $date1[0];
						  $selected = date("l", mktime(0, 0, 0, $month, $day, $year));
						  $month_selected = date("F", mktime(0, 0, 0, $month));
					  ?>
                                  <tr> 
                                    <td height="24" colspan="3" align="left" class="txt"> 
                                      <? 
									  if($option == 1)
									  {
									  	echo"On ".$month_selected." ".$day." , ".$year."(".$selected.").<br>";
									  }
									  if($option == 2)
									  {
									  	echo"Every ".$day."th of the month since ".$month_selected." ".$year.".";
									  }
									  if($option == 3)
									  {
									  	echo"Every ".$selected." since ".$month_selected." ".$day.", ".$year;
									  }
									  if($option == 4)
									  {
									  	echo"On ".$month_selected." ".$day." every year since ".$year;
									  }
									  ?>                                    </td>
                                    <td align="left" class="txt"><input type="button"  value="Delete" class="button" onClick="pass(<? echo $staff_id; ?>, <? echo $data['off_id'];?>, <? echo $business_id; ?>)"></td>
                                  </tr>
                                  <tr> 
                                    <td height="24" colspan="4" align="center" class="header-txt">&nbsp;</td>
                                  </tr>
                                  <? 
								     }
								  } 
								  
								  if(isset($_REQUEST['err'])) 
								  { 
								        if($_REQUEST['err']==1)
										{
								  ?>
											<tr> 
												<td height="24" colspan="4" align="center"><span class="errTxt">Both Fields are Mendatory </span></td>
											</tr>
								  <? 
								        }
								  }
								  
								  ?>
                                  <tr> 
                                    <td height="24" colspan="4" align="center" bgcolor="#EAEAEA" class="header-txt">Add 
                                      New Day Off </td>
                                  </tr>
                                  <tr> 
                                    <td width="19%" align="center" bgcolor="#F7F7F7" class="txt1">Date</td>
                                    <td colspan="3"><input name="date1" type="text" id="date1" value="<?=$d; ?>"/> 
                                      <a href="javascript:cal1.popup();"><img src="calendar/img/cal.gif" alt="Click Here to Pick up the date" width="16" height="16" border="0" align="absmiddle" /></a>&nbsp;&nbsp;<span class="txt">(MM/DD/YYYY)</span>                                    </td>
                                  </tr>
                                  <tr> 
                                    <td bgcolor="#F7F7F7" class="txt">&nbsp;</td>
                                    <td>&nbsp;</td>
                                    <td colspan="2" class="txt">&nbsp;</td>
                                  </tr>
                                  <tr> 
                                    <td bgcolor="#F7F7F7" class="txt">&nbsp;</td>
                                    <td width="3%"><label> 
                                      <input name="radiobutton" type="radio" value="1">
                                      </label></td>
                                    <td width="78%" colspan="2" class="simpletxt">On 
                                      specified date only </td>
                                  </tr>
                                  <tr> 
                                    <td bgcolor="#F7F7F7" class="txt">&nbsp;</td>
                                    <td><label> 
                                      <input name="radiobutton" type="radio" value="2">
                                      </label></td>
                                    <td colspan="2" class="simpletxt">Same day of the 
                                      month every month starting on specified 
                                      date </td>
                                  </tr>
                                  <tr> 
                                    <td bgcolor="#F7F7F7" class="txt">&nbsp;</td>
                                    <td><label> 
                                      <input name="radiobutton" type="radio" value="3">
                                      </label></td>
                                    <td colspan="2" class="simpletxt">Same day of the 
                                    week every week starting on specified date </td>
                                  </tr>
                                  <tr> 
                                    <td bgcolor="#F7F7F7" class="txt">&nbsp;</td>
                                    <td><label> 
                                      <input name="radiobutton" type="radio" value="4">
                                      </label></td>
                                    <td colspan="2" class="simpletxt">Same date every 
                                      year starting on specified date </td>
                                  </tr>
                                  <tr> 
                                    <td colspan="4" align="center" bgcolor="#F7F7F7"><label> 
                                      <input name="add" type="submit" class="button" id="add" value="Add">
                                      </label></td>
                                  </tr>
                                </table></td>
                                  </tr>
                                </table>
                              <table border="0" cellspacing="0" cellpadding="0" align="center" class="box_width_cont product">
                                  <tr>
                                    <td></td>
                                  </tr>
                            </table></td>
                          </tr>
                        </table>
						 <script language="javascript">
								var cal1 = new calendar2(document.forms['frm'].elements['date1']);
								cal1.year_scroll = true;
								cal1.time_comp = false;
						</script>	
						</form>
						
						<table cellpadding="0" cellspacing="0" border="0">
							<tr>
								<td><img src="images/1_q4.gif" border="0" alt="" width="10" height="10"></td>
								<td style="width:100%; background-image:url(images/1_li1.gif)"></td>
								<td><img src="images/1_q3.gif" border="0" alt="" width="10" height="10"></td>
							</tr>
						</table>
						


		
		
		</td>

    <td class="col_right">

<table border="0"cellspacing="0" cellpadding="0" class="box_width_right">
	<tr><td></td>
		<td width="100%">
			<table border="0" cellspacing="0" cellpadding="0">
				<tr><td></td></tr>
			</table>
		</td>
	</tr>
</table>


    </td>
  </tr>
</table>



		</td>
	</tr>
	<tr>
		<td>
			<table cellpadding="0" cellspacing="0" border="0" style="height:98px; background-image:url(images/bot.gif)">
				<tr>
					<td>
						<table cellpadding="0" cellspacing="0" border="0" class="footer">
							<tr>									
								<td height="77"><img src="images/spacer.gif" border="0" alt="" width="25" height="1"></td>				
								<td style="width:207px"><br style="line-height:49px"><img src="images/p1.gif" border="0" alt="" width="145" height="24"><br></td>
							  <td style="width:532px">&nbsp;</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table></td></tr></table>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center"></td>
  </tr>
</table>
</body>

</html>